{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=2
  Verdict: Accepted
}
uses SysUtils;
 
var
	n,m,i,l,r,c,k:longint;
	a:array[-10..10010] of longint;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
read(n,m);
for i:=1 to n do read(a[i]);
for i:=1 to m do begin
	read(k);
	l:=1;
	r:=n;
	c:=(l+r) div 2;
	while r-l>1 do begin
		c:=(l+r) shr 1;
		if a[c]=k then break else
		if a[c]<k then l:=c else r:=c;
	end;
	if (a[l]=k) or (a[r]=k) or (a[c]=k) then writeln(k) else 
	if c=1 then begin
		if abs(a[c]-k)>abs(a[c+1]-k) then writeln(a[c+1]) else writeln(a[c]);
	end else 
	if c=n then begin
		if abs(a[c]-k)>=abs(a[c-1]-k) then writeln(a[c-1]) else writeln(a[c]);
	end else
	if (abs(a[c]-k)<abs(a[c-1]-k)) and (abs(a[c]-k)<=abs(a[c+1]-k)) then writeln(a[c]) else
	if (abs(a[c]-k)>=abs(a[c-1]-k)) and (abs(a[c+1]-k)>=abs(a[c-1]-k)) then writeln(a[c-1]) else
	if (abs(a[c]-k)>abs(a[c+1]-k)) and (abs(a[c-1]-k)>abs(a[c+1]-k)) then writeln(a[c+1]);
end;
end.